﻿Ext.define('app.system.rdcenter.Index',
{
    extend: 'Ext.grid.Panel',
    border: true,
    //title: '研发中心',
    viewConfig: {
        enableTextSelection: true //可以复制单元格文字
    },
    multiColumnSort: true,
    forceFit: true,
    initComponent: function () {
        var me = this;
        me.store = Ext.create("app.ux.PrmStore", { url: '/api/services/app/rdCenter/GetAll' });

        me.tbar = [
            {
                text: localize('Add'), iconCls: "add", handler: function () {
                    var win = Ext.create("app.system.rdcenter.Edit", { title: localize('AddRdCenter') });
                    win.on("savesuccess", function ()
                    {
                        me.store.load();
                        win.close();
                    });
                    win.show();
                }
            }
        ];

        me.callParent(arguments);
    },
    columns: [
        {
            xtype: 'actioncolumn',
            width: 70,
            header: localize('Operating'),
            items: [
            {
                iconCls: 'edit',
                tooltip: localize('Edit'),
                handler: function (grid, rowIndex, colIndex) {
                    var record = grid.store.getAt(rowIndex);
                    var win = Ext.create("app.system.rdcenter.Edit", { title: '编辑研发中心', rdCenterId: record.data.id });
                    win.on("savesuccess", function () {
                        grid.store.load();
                        win.close();
                    });
                    win.show();
                }
            }]
        },
        { header: localize('RdCenter'), dataIndex: 'name' },
        { header: localize('Principal'), dataIndex: 'principal' },
        { header: '事业部', dataIndex: 'businessName' }
    ]
});
